package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.cmn.client.DictFeignClient;
import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.model.hosp.Hospital;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.hosp.vo.hosp.DepartmentVo;
import com.atguigu.yygh.hosp.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;


    @ApiOperation(value = "获取分页列表")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(
            @PathVariable Integer page,
            @PathVariable Integer limit,
            HospitalQueryVo hospitalQueryVo) {
        //按照page limit查询列表数据放在Hospital
        Page<Hospital> pageMode1= hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        List<Hospital> content = pageMode1.getContent();
        long totalElements = pageMode1.getTotalElements();
        return Result.ok(pageMode1);
    }
    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(
            @PathVariable("id") String id,
            @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }
    @ApiOperation(value = "获取医院详情")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(
            @PathVariable String id) {
        Map<String,Object> map=  hospitalService.getHospById(id);
        return Result.ok(map);
    }

}